package org.example.dynamic.controller;

import org.example.dynamic.enetity.FileInfo;
import org.example.dynamic.service.impl.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 文件处理controller
 * 
 * @author Admin
 *
 */
@RestController
@RequestMapping("file")
public class FileController {

    @Autowired
    private IFileService service;

    /**
     * 上传文件
     *
     * @param file
     * @return
     */
    @PostMapping("upload")
    public void save(@RequestPart("file") MultipartFile file) throws IOException {
        service.upload(file);
    }

    @PostMapping("queryImage")
    public Object queryImage(@RequestPart("file") Long id) {
        return service.queryImage(id);
    }
    
}
